package com.android.qjpmc.widget.dialogfragment;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;

import com.android.qjpmc.R;
import com.android.qjpmc.databinding.DialogFragmentMessageBinding;
import com.android.qjpmc.listener.MessageDlialogListener;

public class MessageDialogFragment extends BaseDialogFragment<DialogFragmentMessageBinding> {
    private String content;
    private boolean isLeftCloseDialog;
    private boolean isRightCloseDialog;
    private MessageDlialogListener listener;
    private String rightText;
    private String leftText;

    @Override
    public int getLayoutRes() {
        return R.layout.dialog_fragment_message;
    }

    @Override
    public void initView(Context context, View rootView, AttributeSet attrs) {
        mBinding.setView(this);
    }

    @Override
    public void initData(Context context) {
//        Bundle bundle = getArguments();
        mBinding.tvContent.setText(content);
        mBinding.tvCancel.setText(leftText);
        mBinding.tvDetermine.setText(rightText);
    }

    @Override
    public void initEvent(Context context) {

    }

    @Override
    public void dismiss() {
        super.dismiss();
    }

    public void onNegative(){
        if (isLeftCloseDialog)
            dismiss();
        listener.onLeftClick();
    }

    public void onPositive(){
        if (isRightCloseDialog)
            dismiss();
        listener.onRightClick();
    }

    @Override
    public int getGravity() {
        return Gravity.CENTER;
    }

    public void setMessageConent(String content){
        this.content= content;
    }

    public void setLeftCloseDialog(boolean isLeftCloseDialog) {
        this.isLeftCloseDialog = isLeftCloseDialog;
    }

    public void setRightCloseDialog(boolean isRightCloseDialog) {
        this.isRightCloseDialog = isRightCloseDialog;
    }

    public void setMessageDialogListener(MessageDlialogListener listener){
        this.listener = listener;
    }

    public void setRightText(String rightText) {
        this.rightText = rightText;
    }

    public void setLeftText(String leftText) {
        this.leftText = leftText;
    }
}
